//
//  ZH_ButtonTableViewCell.m
//  BuyProvince
//
//  Created by zhangliwen on 2018/7/7.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_ButtonTableViewCell.h"
@interface ZH_ButtonTableViewCell()
@property (nonatomic,weak)UIButton *loginButton;
@end
@implementation ZH_ButtonTableViewCell

+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_ButtonTableViewCell";
    ZH_ButtonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_ButtonTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
}
- (void)loadSubviewConstraints{
    [self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(24));
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.right.equalTo(self.contentView).offset(FITSCALE(-11));
        make.height.mas_equalTo(FITSCALE(43));
    }];
}
- (void)button{
    if (self.onButtonClicBlock) {
        self.onButtonClicBlock();
    }
}
- (void)updataUI{
    self.loginButton.layer.cornerRadius = FITSCALE(5);
    self.loginButton.layer.masksToBounds = YES;
    self.loginButton.clipsToBounds = YES;
    [self.loginButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(FITSCALE(28));
        make.right.equalTo(self.contentView).offset(FITSCALE(-28));
    }];
}
- (void)updataUIWidth{
    self.loginButton.layer.cornerRadius = FITSCALE(5);
    self.loginButton.layer.masksToBounds = YES;
    self.loginButton.clipsToBounds = YES;
    [self.loginButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(FITSCALE(64));
        make.right.equalTo(self.contentView).offset(FITSCALE(-64));
    }];
}
- (void)updataUIs{
    
    self.loginButton.layer.cornerRadius = FITSCALE(45/2);
    self.loginButton.layer.masksToBounds = YES;
    self.loginButton.clipsToBounds = YES;
    self.loginButton.backgroundColor = [UIColor colorWithHexString:@"#DADADA"];
    [self.loginButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(10));
        make.left.equalTo(self.contentView).offset(FITSCALE(85/2));
        make.right.equalTo(self.contentView).offset(FITSCALE(-85/2));
        make.height.mas_equalTo(FITSCALE(45));
    }];
  
    
}
- (void)updataUIS{
    self.loginButton.layer.cornerRadius = FITSCALE(40/2);
    self.loginButton.layer.masksToBounds = YES;
    self.loginButton.clipsToBounds = YES;
    [self.loginButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(24));
        make.left.equalTo(self.contentView).offset(FITSCALE(85/2));
        make.right.equalTo(self.contentView).offset(FITSCALE(-85/2));
        make.height.mas_equalTo(FITSCALE(40));
    }];
}
- (void)updataUiTitle:(NSString *)titleString{
    [self.loginButton setTitle:titleString forState:UIControlStateNormal];
}
#pragma mark - getter,setter
- (UIButton *)loginButton{
    if(!_loginButton){
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"" target:self action:@selector(button)];
        [button setTitleColor:kFontColorWhite forState:UIControlStateNormal];
        button.titleLabel.font = kFontSize_30;
        button.backgroundColor = [UIColor colorWithHexString:@"#00C9AE"];
        button.layer.cornerRadius = FITSCALE(5);
        button.layer.masksToBounds = YES;
        button.clipsToBounds = YES;
        [self.contentView addSubview:_loginButton = button];
    }
    return _loginButton;
}
@end
